<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"A-3");
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_data = 8;
$pageNum_data = 0;
if (isset($_GET['pageNum_data'])) {
  $pageNum_data = $_GET['pageNum_data'];
}
$startRow_data = $pageNum_data * $maxRows_data;
$cr_txt = str_replace("+"," ",$_REQUEST[q]);
mysql_select_db($database_con_gl, $con_gl);
$query_data = "SELECT * FROM gl_klas";
	if($cr_txt <>'') {
		$query_data .= " where kd ='$cr_txt' OR klasifikasi LIKE '%%$cr_txt%%' OR keterangan LIKE '%%$cr_txt%%'";
	}
$query_data .=" ORDER BY kd,klasifikasi";
$query_limit_data = sprintf("%s LIMIT %d, %d", $query_data, $startRow_data, $maxRows_data);
$data = mysql_query($query_limit_data, $con_gl) or die(mysql_error());
$row_data = mysql_fetch_assoc($data);

if (isset($_GET['totalRows_data'])) {
  $totalRows_data = $_GET['totalRows_data'];
} else {
  $all_data = mysql_query($query_data);
  $totalRows_data = mysql_num_rows($all_data);
}
$totalPages_data = ceil($totalRows_data/$maxRows_data)-1;

$queryString_data = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_data") == false && 
        stristr($param, "totalRows_data") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_data = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_data = sprintf("&totalRows_data=%d%s", $totalRows_data, $queryString_data);
include('include/widget_exportdata.php');
?>
<h1>Klasifikasi Akun</h1>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
  <tr class="hide">
    <td colspan="2"><?php if(strstr($_SESSION[akses],"A-3-1")) { ?><a href="index.php?component=klasifikasiakun&task=add"><img src="images/add_new.png" border="0" /></a><?php } ?></td>
    <td>&nbsp;</td>
    <td colspan="4" align="right"><form id="search" name="search" method="post" action="">
      <label></label>
      <label>
      <input name="cr_txt" type="text" id="cr_txt" placeholder="Find by: kode Akun, klasifikasi, keterangan"; onclick="this.value='';"<?php echo $cr_txt;?>" size="40" maxlength="100" />
      </label>
      <label>
      <input name="Search" type="submit" id="Search" value="Search" />
      </label>
    </form><?php
	if(isset($_POST['Search'])) {
		echo "<script>window.location=\"index.php?component=klasifikasiakun&q=".str_replace(" ","+",$_POST[cr_txt])."\";</script>";
	}
	?></td>
  </tr>
  <tr>
    <th width="8%" align="center"><strong>Kode </strong></th>
    <th width="24%"><strong>Klasifikasi</strong></th>
    <th><strong>Keterangan</strong></th>
    <th width="10%" align="center"><strong>Neraca</strong></th>
    <th width="10%" align="center"><strong>Rugi/Laba</strong></th>
    <th width="10%" align="center"><strong>Tipe</strong></th>
    <th width="125" align="center" class="hide"><strong>Aksi</strong></th>
  </tr>
  <?php if($totalRows_data > 0) { ?>
  <?php do { ?>
  <tr valign="top" bgcolor="#FFFFFF">
    <td align="center"><?php echo $row_data['kd']; ?></td>
    <td><?php echo $row_data['klasifikasi']; ?></td>
    <td><?php echo $row_data['keterangan']; ?>&nbsp;</td>
    <td align="center"><?php if($row_data['neraca']=='1'){ echo "Aktiva";}else if($row_data['neraca']=='2') { echo "Pasiva";}else{ echo "Tidak diset";} ?></td>
    <td align="center"><?php if($row_data['ruglab']=='1'){ echo "Penghasilan Usaha";}else if($row_data['ruglab']=='2') { echo "Beban Usaha";}else{ echo "Tidak diset";} ?></td>
    <td align="center"><?php if($row_data['tipe']=='2') { echo "Kas & Bank";}else if($row_data['tipe']=='3') { echo "Persediaan";}else if($row_data['tipe']=='4') { echo "HPP";}else if($row_data['tipe']=='5') { echo "Penjualan";}else if($row_data['tipe']=='7') { echo "Hutang";}else if($row_data['tipe']=='6') { echo "Piutang";}else if($row_data['tipe']=='8') { echo "Penawaran";}else if($row_data['tipe']=='9') { echo "Pajak";}else if($row_data['tipe']=='10') { echo "Biaya Lain";}else{ echo "Tidak diset";} ?></td>
    <td align="center" class="hide"><?php if(strstr($_SESSION[akses],"A-3-2")) { ?><a href="index.php?component=klasifikasiakun&amp;task=edit&amp;id=<?php echo $row_data['kd']; ?>"><img src="images/edit_.png" border="0" /></a><?php } ?> <?php if(strstr($_SESSION[akses],"A-3-3")) { ?><a href="index.php?component=klasifikasiakun&amp;task=delete&amp;id=<?php echo $row_data['kd']; ?>" class="ask"><img src="images/delete_.png" border="0" /></a><?php } ?></td>
  </tr>
  <?php } while ($row_data = mysql_fetch_assoc($data)); ?>
  <?php if($totalRows_data > $maxRows_data) { ?>
  <tr class="hide">
    <td colspan="7"  style="border-bottom:solid 1px #E2EAC1;border-right:solid 1px #E2EAC1;border-left:solid 1px #E2EAC1;"><table border="0" align="left" id="pagination">
      <tr>
        <td width="23%" align="center"><?php if ($pageNum_data > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_data=%d%s", $currentPage, 0, $queryString_data); ?>"><img src="First.gif" border="0" /></a>
            <?php } // Show if not first page ?>
        </td>
        <td width="31%" align="center"><?php if ($pageNum_data > 0) { // Show if not first page ?>
            <a href="<?php printf("%s?pageNum_data=%d%s", $currentPage, max(0, $pageNum_data - 1), $queryString_data); ?>"><img src="Previous.gif" border="0" /></a>
            <?php } // Show if not first page ?>
        </td>
        <td width="23%" align="center"><?php if ($pageNum_data < $totalPages_data) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_data=%d%s", $currentPage, min($totalPages_data, $pageNum_data + 1), $queryString_data); ?>"><img src="Next.gif" border="0" /></a>
            <?php } // Show if not last page ?>
        </td>
        <td width="23%" align="center"><?php if ($pageNum_data < $totalPages_data) { // Show if not last page ?>
            <a href="<?php printf("%s?pageNum_data=%d%s", $currentPage, $totalPages_data, $queryString_data); ?>"><img src="Last.gif" border="0" /></a>
            <?php } // Show if not last page ?>
        </td>
      </tr>
    </table></td>
  </tr>
  <?php } ?>
  <?php }else{ ?>
  <tr bgcolor="#FFFFFF">
    <td colspan="7"  style="border-bottom:solid 1px #E2EAC1;border-right:solid 1px #E2EAC1;border-left:solid 1px #E2EAC1;">Data tidak ada !!! </td>
  </tr>
  <?php } ?>
  <tr class="hide">
    <td colspan="7"><?php if(strstr($_SESSION[akses],"A-3-1")) { ?><a href="index.php?component=klasifikasiakun&task=add"><img src="images/add_new.png" border="0" /></a><?php } ?></td>
  </tr>
</table>
